#include <iostream>

using namespace std;

class polar
{
private:
	double distance;
	double corner;
public:
	polar(double dist, double corn)
	{
		distance = dist;
		corner = corn;
	}
	void displace(double new_dist, double new_corn)
	{
		distance = new_dist;
		corner = new_corn;
	}

	double getDist()
	{
		return distance;
	}
	double getCorn()
	{
		return corner;
	}
	void getCoord()
	{
		transf();
	}
	pair<double,double> transf()
	{
		pair<double, double> position;
		position.first = distance*cos(corner);
		position.second = distance*sin(corner);
		//cout << "X = " << position.first << endl;
		//cout << "Y = " << position.second << endl;
		return position;
	}
	void printCoord()
	{
		pair<double, double> coordinate;
		coordinate = transf();
		cout << "Coordinate: (" << coordinate.first << ";" << coordinate.second << ")" << endl;
	}
};

double check(double corn)
{
	if (corn < 0)
	{
		while (corn < 0)
		{
			corn = corn + 360;
		}
	}

	else if (corn > 360)
	{
		while (corn > 360)
		{
			corn = corn - 360;
		}
		
	}
	return corn;
}

int main()
{
	double dist;
	double corn;
	cout << "Enter radius and angle" << endl;
	cout << "Radius: ";
	cin >> dist;
	if (dist < 0)
	{
		cout << " Error! Radius can't be negative! Enter it again." << endl;
		cin >> dist;
	}
	cout << "Angle: ";
	cin >> corn;
	check(corn);

	polar A(dist, corn);
	A.getCoord();
	A.transf();
	A.printCoord();

	cout << "Enter new radius and new angle" << endl;
	cout << "Radius: ";
	cin >> dist;
	if (dist < 0)
	{
		cout << " Error! Radius can't be negative! Enter it again." << endl;
		cin >> dist;
	}
	cout << "Angle: "; 
	cin >> corn;
	check(corn);

	A.displace(dist, corn);

	system("pause");
	return 0;

}